/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package main.NER;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import main.KBProcess.Fragment;
import main.Ontology.ElementOntologySet;

/**
 *
 * @author Isaac Osesina
 */
public class DefaultStem extends DefaultBranch implements Stem, Serializable, Cloneable  {
	private static final long serialVersionUID = -4819816902083196343L;
	
	Object stemID;
    private List<Fragment> fragmentList;
 
    public DefaultStem() {
        super();
    }

    public DefaultStem(ElementOntologySet stemID) {
        super(stemID);
    }

    public DefaultStem(Object stemID) {
        super(null);
        this.stemID = stemID;
    }

    public DefaultStem(ElementOntologySet stemID, ElementOntologySet branchID) {
        super(stemID);
        addBranch(branchID);
    }

    @Override
	public Branch addBranch(ElementOntologySet branchID) {
        return this.addChild(branchID);
    }

    @Override
	public Branch addBranch(ElementOntologySet branchID, boolean append, Integer freq, Fragment fragment) {
        addFragment(fragment);        
        this.setAppend(append);
        this.setFragmentSample(fragment);
        if(branchID !=null){
                if(!branchID.isEmpty()) {
                    this.incrementMyType(freq);
                }
                else if(branchID.isEmpty() && freq != null){                
                    this.setNonCousinTypeCount(freq);
                }
        }
        return this.addChild(branchID, append, freq, fragment);
    }

    @Override
    public Branch updateFruit_Terminator(ElementOntologySet branchID, Fragment fragment) {
        this.setTerminator(true);
        this.addTerminatingFragment(fragment);
        return super.updateFruit_Terminator(branchID, fragment);
    }

    @Override
	public Branch removeBranch(ElementOntologySet branchID) {
        return this.remove(branchID);
    }

    @Override
	public Object getStemID() {
        return stemID;
    }

    @Override
	public void setStemID(Object stemID) {
        this.stemID = stemID;
    }

    @Override
	public void addFragment(Fragment fragment) {
        if(fragment != null) {
            fragmentList = fragmentList==null ? new ArrayList<Fragment>():fragmentList;
            fragmentList.add(null);
        }
    }

    @Override
	public List<Fragment> getFragmentList() {
        return fragmentList;
    }
}
